package jiggle;

public class ProjectionConstraint extends ForceLaw implements Constraint {

	private int dimensions = 0;

	public ProjectionConstraint (Graph g, int d) {
		super (g); dimensions = d;
	}
	
	@Override
    public void apply (double [][] penalty) {
		int d = graph.getDimensions ();
		int n = graph.getNumberOfVertices();
		for (int i = 0; i < n; i++) {
			double coords [] = graph.vertices.get(i).getCoords ();
			for (int j = dimensions; j < d; j++) {
				penalty [i] [j] += (- coords [j]);
			}
		}
	}
}

